package com.example.learnvien.ui;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.learnvien.data.NumberItemData;

public class GridViewNumberAdapter extends BaseAdapter
{
    private List<NumberItemData> mItemDatas;
    private Context mContext;

    public GridViewNumberAdapter(Context context, List<NumberItemData> datas)
    {
        mContext = context;
        mItemDatas = datas == null ? new ArrayList<NumberItemData>() : datas;
    }

    @Override
    public int getCount()
    {
        return mItemDatas.size();
    }

    @Override
    public Object getItem(int arg0)
    {
        return mItemDatas.get(arg0);
    }

    @Override
    public long getItemId(int arg0)
    {
        return 0;
    }

    @Override
    public View getView(int position, View arg1, ViewGroup arg2)
    {
    	NumberItemData itemData = (NumberItemData) getItem(position);
    	if(itemData == null)
    	{
    		return null;
    	}
    	
    	ImageView view = new ImageView(mContext);
        view.setImageDrawable(itemData.mImageIcon);
        return view;
    }
}
